package template.page;

import java.security.Principal;

import org.apache.log4j.Logger;

import org.apache.click.Context;
import org.apache.click.Page;

/**
 *  Provides the base page with include business services, which
 *  other application pages should extend.
 */
public class BasePage extends Page {

    private static final long serialVersionUID = 1L;

    protected Logger logger;    
    
    /**
     * Return the class logger.
     *
     * @return the class logger
     */
    public Logger getLogger() {
        if (logger == null) {
            logger = Logger.getLogger(getClass());
        }
        return logger;
    }
    
    protected String getCurrentUser() 
    {
    	String currentUser=null;
    	Context context = getContext();
		if (context!=null) 
		{
			Principal principal = context.getRequest().getUserPrincipal();
			if (principal != null) 
			{
				currentUser = principal.getName();
			}
		}
		return currentUser;
    }
}
